package com.cr.admin.business.authentication.controller;

import com.cr.admin.business.authentication.pojo.dto.param.AuthenticationSaveParam;
import com.cr.admin.business.authentication.pojo.dto.param.AuthenticationUpdateParam;
import com.cr.admin.business.authentication.pojo.dto.query.AuthenticationQuery;
import com.cr.admin.business.authentication.pojo.entity.Authentication;
import com.cr.admin.business.authentication.pojo.vo.AuthenticationVO;
import com.cr.admin.business.authentication.service.AuthenticationService;
import com.cr.admin.business.banner.pojo.entity.Banner;
import com.cr.admin.business.banner.pojo.param.BannerUpdateParam;
import com.cr.admin.business.banner.pojo.query.BannerQuery;
import com.cr.common.response.JsonResult;

import com.cr.common.response.PageData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@Api(tags = "证件验证模块")
@RequestMapping("/api/bus/users/authentication")
public class AuthenticationController {
    @Autowired
    private AuthenticationService authenticationService;

    @ApiOperation(value = "查询证件列表")
    @GetMapping
    public JsonResult list(AuthenticationQuery authenticationQuery) {
        PageData<AuthenticationVO> pageData = PageData.page(authenticationQuery.getPageNum(), authenticationQuery.getPageSize(),
                () -> authenticationService.list(authenticationQuery));
        return JsonResult.success(pageData);
    }

    @ApiOperation(value = "新增证件验证")
    @PostMapping
    public JsonResult addAuthentication(@Validated @RequestBody AuthenticationSaveParam authenticationSaveParam){
        authenticationService.addAuthentication(authenticationSaveParam);
        return JsonResult.success();
    }
    @ApiOperation(value = "查询证件验证")
    @GetMapping("{id}")
    public JsonResult getAuthenticationDetail(@PathVariable Long id){
        AuthenticationVO authenticationVO = authenticationService.getAuthenticationDetail(id);
        return JsonResult.success(authenticationVO);
    }

    @ApiOperation(value = "修改证件验证")
    @PutMapping()
    public JsonResult update(@Validated @RequestBody AuthenticationUpdateParam authenticationUpdateParam) {
        authenticationService.updateById(authenticationUpdateParam);
        return JsonResult.success();
    }

    @ApiOperation(value = "删除证件验证")
    @DeleteMapping()
    public JsonResult delete(@RequestParam(name = "ids") List<Long> ids){
        authenticationService.deleteByIds(ids);
        return JsonResult.success();
    }





}
